<template>
  <div>
    <ul>
        <li v-for="(v,index) in list" :key="index" @click="fun(index)">
            <img :src="v.pic" alt="">
            <p>{{ v.title }}</p>
        </li>
    </ul>
  </div>
</template>

<script>
import service from "../../../utils/service";
export default {
  name: "list",
  data() {
    return {
      list: [],
    };
  },
  methods:{
    fun(index){
        
        console.log(index);
        if(index == 1){
          this.$router.push('/caizhuang').catch(err=>{});
        }
    }
  },
  mounted() {
    service({
      url: "navlist",
      method: "get",
    }).then((res) => {
      console.log(res.data);
      res.data.forEach((item) => {
        this.list.push(item);
      });
    });
  },
};
</script>

<style scoped>
ul{
    height: 176px;
    display: flex;
    flex-wrap: wrap;
    overflow: auto;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    background-color: white;
    font-size: 12px;
}
li{
    width:20%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
li img{
    width: 50px;
    height: 50px;
}
</style>